package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author fy
 * @version V1.0
 * @Project workspace
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/16 1:24
 */
@Controller
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 查询所有用户返回
     * @return
     */
    @RequestMapping("/list")
    public String userList(Model model){
        //1.查找所有用户数据
        List<User> list = userService.findUserAll();

        //2.放入model中
        model.addAttribute("users", list);
        return "user";
    }
}
